home *** CD-ROM | disk | FTP | other *** search
- static void BuildSky16(unsigned short int *out, unsigned char *in)
- {
- int size;
-
- for (size = (SKY_X * SKY_Y) - 1; size >= 0; size--) {
- struct rgb *pel = &cachedPalette[*in++];
-
- /*unsigned short int red = ((unsigned short int)(*((unsigned char *)pel)++) >> (8 - 5)); */
- /*unsigned short int green = ((unsigned short int)(*((unsigned char *)pel)++) >> (8 - 6)); */
- /*unsigned short int blue = ((unsigned short int)(*((unsigned char *)pel)) >> (8 - 5)); */
- /**out++ = (red << (6 + 5)) | (green << 5) | (blue); */
- *out++ = (((unsigned short int)(pel->r) >> (8 - 5)) << (6 + 5)) |
- (((unsigned short int)(pel->g) >> (8 - 6)) << 5) |
- (((unsigned short int)(pel->b) >> (8 - 5)));
- }
- }
-
- static void BuildLightBlock16(unsigned short int *out, struct bitmap *raw, int x, int y)
- {
- int c, dc;
- int a, b, h, c0, c1, c2, c3;
- int y_max = raw->height, x_max = raw->width;
- unsigned char *fullbright = raw->data + lookup(y, raw->width);
-
- c0 = ((255 << 6) - lightmapIndex[0]);
- c1 = ((255 << 6) - lightmapIndex[1]);
- c2 = ((255 << 6) - lightmapIndex[lightmapWidth]);
- c3 = ((255 << 6) - lightmapIndex[lightmapWidth + 1]);
-
- c2 = (c2 - c0) >> shift;
- c3 = (c3 - c1) >> shift;
-
- for (b = 0; b < step; ++b) {
- h = x;
- c = c0;
- dc = (c1 - c0) >> shift;
- for (a = 0; a < step; ++a) {
- struct rgb *pel = &cachedPalette[fullbright[h]];
- unsigned short int red = ((unsigned short int)(*((unsigned char *)pel)++) >> (8 - 5));
- unsigned short int green = ((unsigned short int)(*((unsigned char *)pel)++) >> (8 - 6));
- unsigned short int blue = ((unsigned short int)(*((unsigned char *)pel)) >> (8 - 5));
-
- /*if((red = (red * c) >> (5 + 8)) > 0x1F) */
- /* red = 0x1F; */
- /*if((green = (green * c) >> (5 + 8)) > 0x1F) */
- /* green = 0x1F; */
- /*if((blue = (blue * c) >> (5 + 8)) > 0x1F) */
- /* blue = 0x1F; */
- *out++ = (red << 11) | (green << 5) | (blue);
- c += dc;
- if (++h == x_max)
- h = 0;
- }
- out += row;
- c0 += c2;
- c1 += c3;
- if (++y == y_max) {
- y = 0;
- fullbright = raw->data;
- }
- else
- fullbright += raw->width;
- }
- }
-
- static unsigned short int brightColorshift;
- static void BuildBrightBlock16(unsigned short int *out, struct bitmap *raw, int x, int y)
- {
- int a, b, h;
- int y_max = raw->height, x_max = raw->width;
- unsigned char *fullbright = raw->data + lookup(y, raw->width);
-
- for (b = 0; b < step; ++b) {
- h = x;
- for (a = 0; a < step; ++a) {
- struct rgb *pel = &cachedPalette[fullbright[h]];
- unsigned short int red = ((unsigned short int)(*((unsigned char *)pel)++) >> (8 - 5));
- unsigned short int green = ((unsigned short int)(*((unsigned char *)pel)++) >> (8 - 6));
- unsigned short int blue = ((unsigned short int)(*((unsigned char *)pel)) >> (8 - 5));
-
- /*red = red >> brightColorshift; */
- /*green = green >> brightColorshift; */
- /*blue = blue >> brightColorshift; */
- *out++ = (red << 11) | (green << 5) | (blue);
- if (++h == x_max)
- h = 0;
- }
- out += row;
- if (++y == y_max) {
- y = 0;
- fullbright = raw->data;
- }
- else
- fullbright += raw->width;
- }
- }
-